package set;
import set.Student;


import java.util.Comparator;
import java.util.TreeSet;

public class TreeSetDemo1 {
//    TreeSet集合特点：排序和去重

    public static void main(String[] args) {
        TreeSet<String> ts=new TreeSet<>(new Comparator<String> (){
            @Override
            public int compare(String o1,String o2){
                return o2.length()-o1.length();
            }
        });
        ts.add("art");
        ts.add("btre");
        ts.add("drewrrew");
        ts.add("f");
        ts.add("cewrew");
        ts.add("dwerew");
        ts.add("fw");
        ts.add("cwerew");
        System.out.println(ts);
        TreeSet<Student> stu=new TreeSet<>();
        stu.add(new Student("zhangsan",20));
        stu.add(new Student("lisi",25));
        stu.add(new Student("liso",23));
        stu.add(new Student("lisi",25));
        stu.add(new Student("brusi",25));
        System.out.println(stu);
    }
}
